# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=maligno
pkgver=2.5
pkgrel=6
groups=('blackarch' 'blackarch-scanner' 'blackarch-fuzzer' 'blackarch-exploitation')
pkgdesc='An open source penetration testing tool written in python, that serves Metasploit payloads. It generates shellcode with msfvenom and transmits it over HTTP or HTTPS.'
arch=('any')
url='http://www.encripto.no/tools/'
license=('BSD')
depends=('python2' 'python2-lxml' 'python2-pycryptodome' 'metasploit'
         'python2-ipcalc')
source=("http://www.encripto.no/tools/$pkgname-$pkgver.tar.gz")
sha512sums=('7386b5ee536c2bb92eed0ad64b33ce6afc16d175fec01904da90bce46ffc7302626c5d5624cdcf4a2c38825cf4806f1238931db78ccd482002245177382ee099')

prepare() {
  cd "$pkgname-$pkgver"

  sed -i 's|/usr/bin/python|/usr/bin/python2|g' maligno_srv.py
  sed -i 's|/usr/bin/python|/usr/bin/python2|g' clientgen.py
}

package() {
  cd "$pkgname-$pkgver"

  _tools="maligno_srv clientgen"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" docs/*

  rm -rf docs

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/maligno-srv" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 maligno_srv.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/maligno-srv"

  cat > "$pkgdir/usr/bin/maligno-clientgen" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 clientgen.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/maligno-clientgen"
}

